<?php

/**
 * @author      Nguyen Duc Thuan <me@ndthuan.com>
 * @copyright   Copyright (c) 2009 Nguyen Duc Thuan <me@ndthuan.com>
 */
class Fete_View_Helper_DocType extends Fete_View_Helper
{
    protected $_docType = 'UNDEFINED';

    public function &docType($docType = null)
    {
        if (null !== $docType) {
            $this->_docType = strtoupper($docType);
        }

        return $this;
    }

    public function getDocType()
    {
        return $this->_docType;
    }

    public function __toString()
    {
        switch ($this->_docType)
        {
            case 'HTML 3.2':
                return '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">';
            case 'HTML 4.01 TRANSITIONAL':
                return '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01
                    Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">';
            case 'HTML 4.01 STRICT':
                return '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
                    "http://www.w3.org/TR/html4/strict.dtd">';
            case 'HTML 4.01 FRAMESET':
                return '<!DOCTYPE html PUBLIC 
                    "-//W3C//DTD HTML 4.01 Frameset//EN"
                    "http://www.w3.org/TR/html4/frameset.dtd">';
            case 'HTML 5.0':
                return '<!DOCTYPE html>';
            case 'XHTML 1.0 TRANSITIONAL':
                return '<?xml version="1.0" encoding="UTF-8" ?>
                    <!DOCTYPE html PUBLIC
                    "-//W3C//DTD XHTML 1.0 Transitional//EN"
                    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">';
            case 'XHTML 1.0 STRICT':
                return '<?xml version="1.0" encoding="UTF-8" ?>
                    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
                    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">';
            case 'XHTML 1.0 FRAMESET':
                return '<?xml version="1.0" encoding="UTF-8" ?>
                    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
                    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">';
            case 'XHTML 1.1':
                return '<?xml version="1.0" encoding="UTF-8" ?>
                    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
                    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">';
            case 'XHTML 2.0':
                return '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 2.0//EN"
                    "http://www.w3.org/MarkUp/DTD/xhtml2.dtd">';
            default:
                return '<!DOCTYPE HTML PUBLIC
                    "-//W3C//DTD HTML 4.01 Transitional//EN">';
        }
    }
}